﻿/*
 * Amkai Enterprise Solution (AES.) 
 * Copyright 2004 by Amkai(TM), Inc.
 * www.amkai.com
 * 
 * Project: webservice
 * Package: com.amkai.aes.webservice.binary
 * File: JobManager.java
 * Created: Sep 2, 2005 9:58:56 PM
 * Author: Miskolczi P�ter 
 * 
 */
package com.amkai.aes.webservice.binary;

import java.io.Serializable;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.amkai.aes.aescommon.AESSettings;
import com.amkai.aes.aescommon.exceptions.HandlerNotFoundException;
import com.amkai.aes.aescommon.service.binary.job.AgingCalculatorJob;
import com.amkai.aes.aescommon.service.binary.job.AmkaiRxRegistrationJob;
import com.amkai.aes.aescommon.service.binary.job.AppointmentsToRegistrationJob;
import com.amkai.aes.aescommon.service.binary.job.BatchCalculatorJob;
import com.amkai.aes.aescommon.service.binary.job.BatchInformationJob;
import com.amkai.aes.aescommon.service.binary.job.BatchValidatorJob;
import com.amkai.aes.aescommon.service.binary.job.BinaryUploadCommitJob;
import com.amkai.aes.aescommon.service.binary.job.ChartDocAppAssocJob;
import com.amkai.aes.aescommon.service.binary.job.ClientSettingsJob;
import com.amkai.aes.aescommon.service.binary.job.CreateNewObjectJob;
import com.amkai.aes.aescommon.service.binary.job.DepartmentsListJob;
import com.amkai.aes.aescommon.service.binary.job.DesktopContentJob;
import com.amkai.aes.aescommon.service.binary.job.DictionaryDataRequestJob;
import com.amkai.aes.aescommon.service.binary.job.DomainCommitterJob;
import com.amkai.aes.aescommon.service.binary.job.ExternalIdJob;
import com.amkai.aes.aescommon.service.binary.job.FacilityListJob;
import com.amkai.aes.aescommon.service.binary.job.FormsProviderJob;
import com.amkai.aes.aescommon.service.binary.job.ForsImportJob;
import com.amkai.aes.aescommon.service.binary.job.GeneralJob;
import com.amkai.aes.aescommon.service.binary.job.GetAllSuperBillTypeJob;
import com.amkai.aes.aescommon.service.binary.job.InsurancePolicyCaseVerificationCommiterJob;
import com.amkai.aes.aescommon.service.binary.job.IsPartiallySharedItemRequiredFieldsFilledJob;
import com.amkai.aes.aescommon.service.binary.job.ItemJob;
import com.amkai.aes.aescommon.service.binary.job.Job;
import com.amkai.aes.aescommon.service.binary.job.JobManagerInterface;
import com.amkai.aes.aescommon.service.binary.job.KeepSessionJob;
import com.amkai.aes.aescommon.service.binary.job.ListJob;
import com.amkai.aes.aescommon.service.binary.job.LoginJob;
import com.amkai.aes.aescommon.service.binary.job.LoginRelatedOperationsJob;
import com.amkai.aes.aescommon.service.binary.job.LogoutJob;
import com.amkai.aes.aescommon.service.binary.job.OccupationTransferJob;
import com.amkai.aes.aescommon.service.binary.job.PassportListJob;
import com.amkai.aes.aescommon.service.binary.job.PassportManagerJob;
import com.amkai.aes.aescommon.service.binary.job.PeriodAndBatchJob;
import com.amkai.aes.aescommon.service.binary.job.PersonInsuranceInfoJob;
import com.amkai.aes.aescommon.service.binary.job.PersonRelationshipsJob;
import com.amkai.aes.aescommon.service.binary.job.PersonUniqueJob;
import com.amkai.aes.aescommon.service.binary.job.PhysStaffJob;
import com.amkai.aes.aescommon.service.binary.job.ProcedureCarrierCodeJob;
import com.amkai.aes.aescommon.service.binary.job.RADBeanSaveJob;
import com.amkai.aes.aescommon.service.binary.job.RADBeanUniquePropertyJob;
import com.amkai.aes.aescommon.service.binary.job.RemarkJob;
import com.amkai.aes.aescommon.service.binary.job.RemittancePostingJob;
import com.amkai.aes.aescommon.service.binary.job.RequestJob;
import com.amkai.aes.aescommon.service.binary.job.SearchCountJob;
import com.amkai.aes.aescommon.service.binary.job.SearchJob;
import com.amkai.aes.aescommon.service.binary.job.SettingPropertyJob;
import com.amkai.aes.aescommon.service.binary.job.TreeNodeJob;
import com.amkai.aes.aescommon.service.binary.job.UpLoadJob;
import com.amkai.aes.aescommon.service.binary.job.UpdateJob;
import com.amkai.aes.aescommon.service.binary.job.ValidationJob;
import com.amkai.aes.aescommon.service.binary.job.VersionTitleAndSupportedVersionsGetterJob;
import com.amkai.aes.aescommon.service.binary.job.acsupport.ACLoginSupportGetterJob;
import com.amkai.aes.aescommon.service.binary.job.acsupport.ACLoginSupportSelectorJob;
import com.amkai.aes.aescommon.service.binary.job.audittrail.AuditTrailJob;
import com.amkai.aes.aescommon.service.binary.job.billing.AnesthesiaCalculationGetterJob;
import com.amkai.aes.aescommon.service.binary.job.billing.AutoPostingJob;
import com.amkai.aes.aescommon.service.binary.job.billing.BatchJob;
import com.amkai.aes.aescommon.service.binary.job.billing.BillingJob;
import com.amkai.aes.aescommon.service.binary.job.billing.ChargeEntryJob;
import com.amkai.aes.aescommon.service.binary.job.billing.ChargeImportJob;
import com.amkai.aes.aescommon.service.binary.job.billing.ChargeProviderJob;
import com.amkai.aes.aescommon.service.binary.job.billing.ClaimCustomizationJob;
import com.amkai.aes.aescommon.service.binary.job.billing.DeleteBatchJob;
import com.amkai.aes.aescommon.service.binary.job.billing.GroupRebillJob;
import com.amkai.aes.aescommon.service.binary.job.billing.ImportCheckoutJob;
import com.amkai.aes.aescommon.service.binary.job.billing.InsuranceBillingHistoryJob;
import com.amkai.aes.aescommon.service.binary.job.billing.InsuranceBillingJob;
import com.amkai.aes.aescommon.service.binary.job.billing.LedgerJob;
import com.amkai.aes.aescommon.service.binary.job.billing.LedgerSettingsJob;
import com.amkai.aes.aescommon.service.binary.job.billing.PatientStatementHistoryJob;
import com.amkai.aes.aescommon.service.binary.job.billing.PeriodJob;
import com.amkai.aes.aescommon.service.binary.job.billing.PrintBillJob;
import com.amkai.aes.aescommon.service.binary.job.billing.TransferToBgJob;
import com.amkai.aes.aescommon.service.binary.job.billing.ledger.PWTJob;
import com.amkai.aes.aescommon.service.binary.job.casecosting.CaseCostingJob;
import com.amkai.aes.aescommon.service.binary.job.casecosting.CaseCostingParameterJob;
import com.amkai.aes.aescommon.service.binary.job.casehistory.ASCAnesthesiaImportJob;
import com.amkai.aes.aescommon.service.binary.job.casehistory.CDMImporterJob;
import com.amkai.aes.aescommon.service.binary.job.casehistory.CaseHistoryHelperJob;
import com.amkai.aes.aescommon.service.binary.job.casehistory.CaseHistoryJob;
import com.amkai.aes.aescommon.service.binary.job.casehistory.CaseHistorySyncJob;
import com.amkai.aes.aescommon.service.binary.job.casehistory.ChartDocumentsJob;
import com.amkai.aes.aescommon.service.binary.job.casehistory.ImportCDMJob;
import com.amkai.aes.aescommon.service.binary.job.casehistory.IsBilledJob;
import com.amkai.aes.aescommon.service.binary.job.casehistory.PreferenceCardLoaderJob;
import com.amkai.aes.aescommon.service.binary.job.casehistory.SerialNumberJob;
import com.amkai.aes.aescommon.service.binary.job.casehistory.SharedDictionaryJob;
import com.amkai.aes.aescommon.service.binary.job.checkexistence.CheckExistenceJob;
import com.amkai.aes.aescommon.service.binary.job.contract.ContractImportJob;
import com.amkai.aes.aescommon.service.binary.job.contract.ContractJob;
import com.amkai.aes.aescommon.service.binary.job.contract.TransientContractProviderJob;
import com.amkai.aes.aescommon.service.binary.job.dictionary.DictionaryActivationJob;
import com.amkai.aes.aescommon.service.binary.job.dictionary.DictionaryDeactivatingValidatorJob;
import com.amkai.aes.aescommon.service.binary.job.dictionary.DictionaryEditorSavingValidationJob;
import com.amkai.aes.aescommon.service.binary.job.dictionary.GetItemInCurrentOrGivenBusinessEntityJob;
import com.amkai.aes.aescommon.service.binary.job.dictionary.GetStateCodeValuesJob;
import com.amkai.aes.aescommon.service.binary.job.dictionary.GetStatesForDepartmentsJob;
import com.amkai.aes.aescommon.service.binary.job.dictionary.InsuranceClaimOfficeAndPlanDeleteValidationJob;
import com.amkai.aes.aescommon.service.binary.job.dictionary.IsContractSetForPlanPoliciesJob;
import com.amkai.aes.aescommon.service.binary.job.dictionary.IsPhysStaffPersonIdExistJob;
import com.amkai.aes.aescommon.service.binary.job.dictionary.ItemSkeletonGetterJob;
import com.amkai.aes.aescommon.service.binary.job.dictionary.ItemStateCodesGetterJob;
import com.amkai.aes.aescommon.service.binary.job.erp.ElectronicRemittancePostingJob;
import com.amkai.aes.aescommon.service.binary.job.feeschedule.FeeScheduleJob;
import com.amkai.aes.aescommon.service.binary.job.init.InitializationJob;
import com.amkai.aes.aescommon.service.binary.job.inventory.BEFacilitiesAddressJob;
import com.amkai.aes.aescommon.service.binary.job.inventory.DepratmentFacilitiesJob;
import com.amkai.aes.aescommon.service.binary.job.inventory.DictionaryItemSearchJob;
import com.amkai.aes.aescommon.service.binary.job.inventory.InventoryElementCalculatorJob;
import com.amkai.aes.aescommon.service.binary.job.inventory.InventoryJob;
import com.amkai.aes.aescommon.service.binary.job.inventory.OrderRequisitionNumberJob;
import com.amkai.aes.aescommon.service.binary.job.inventory.OrderRequisitionsJob;
import com.amkai.aes.aescommon.service.binary.job.inventory.PhysicalInventoryJob;
import com.amkai.aes.aescommon.service.binary.job.inventory.PoNumberJob;
import com.amkai.aes.aescommon.service.binary.job.inventory.PurchaseOrderLinesJob;
import com.amkai.aes.aescommon.service.binary.job.inventory.PurchaseOrderNumberCheckerJob;
import com.amkai.aes.aescommon.service.binary.job.inventory.PurchaseOrdersJob;
import com.amkai.aes.aescommon.service.binary.job.inventory.RADBeanQueryJob;
import com.amkai.aes.aescommon.service.binary.job.inventory.SimpleItemJob;
import com.amkai.aes.aescommon.service.binary.job.inventory.SupplyResourceItemJob;
import com.amkai.aes.aescommon.service.binary.job.inventory.VendorOrderInformationJob;
import com.amkai.aes.aescommon.service.binary.job.inventory.VendorOrderInformationPropertiesJob;
import com.amkai.aes.aescommon.service.binary.job.inventory.VendorOrderManufacterJob;
import com.amkai.aes.aescommon.service.binary.job.inventory.epo.ElectronicPurchaseOrderJob;
import com.amkai.aes.aescommon.service.binary.job.inventory.hql.AesCriteriaJob;
import com.amkai.aes.aescommon.service.binary.job.license.LicenseJob;
import com.amkai.aes.aescommon.service.binary.job.locking.LockJob;
import com.amkai.aes.aescommon.service.binary.job.organization.AreDataRecordedForDepartmentJob;
import com.amkai.aes.aescommon.service.binary.job.organization.EnterpriseTreeJob;
import com.amkai.aes.aescommon.service.binary.job.personnel.PersonnelJob;
import com.amkai.aes.aescommon.service.binary.job.personnel.PrivilegeProcedureJob;
import com.amkai.aes.aescommon.service.binary.job.prefcards.PhysStaffLoaderJob;
import com.amkai.aes.aescommon.service.binary.job.prefcards.PrefCardPrinterPatientQueryJob;
import com.amkai.aes.aescommon.service.binary.job.prefcards.PreferenceCardJob;
import com.amkai.aes.aescommon.service.binary.job.prefcards.PreferenceCardQueryJob;
import com.amkai.aes.aescommon.service.binary.job.preference.PreferenceJob;
import com.amkai.aes.aescommon.service.binary.job.registration.BgSpecificPropertiesJob;
import com.amkai.aes.aescommon.service.binary.job.registration.EstimatedRevenueJob;
import com.amkai.aes.aescommon.service.binary.job.registration.FreeAppointmentsJob;
import com.amkai.aes.aescommon.service.binary.job.registration.GetEnterpriseCasesJob;
import com.amkai.aes.aescommon.service.binary.job.registration.InsurancePlanJob;
import com.amkai.aes.aescommon.service.binary.job.registration.InsurancePolicyCaseVerifiationJob;
import com.amkai.aes.aescommon.service.binary.job.registration.LoadSpecifiedRegistrationDataJob;
import com.amkai.aes.aescommon.service.binary.job.registration.PatientBalanceCheckingJob;
import com.amkai.aes.aescommon.service.binary.job.registration.PatientLabelJob;
import com.amkai.aes.aescommon.service.binary.job.registration.PmCaseJob;
import com.amkai.aes.aescommon.service.binary.job.registration.RegistrationJob;
import com.amkai.aes.aescommon.service.binary.job.registration.RegistrationValidationJob;
import com.amkai.aes.aescommon.service.binary.job.relationship.PersonRelationshipJob;
import com.amkai.aes.aescommon.service.binary.job.schedule.AvailableResourcesConflictCheckingJob;
import com.amkai.aes.aescommon.service.binary.job.schedule.CaseCommitJob;
import com.amkai.aes.aescommon.service.binary.job.schedule.IsPreferenceCardLoadedForAppointmentInCDMJob;
import com.amkai.aes.aescommon.service.binary.job.security.SecurityManagerJob;
import com.amkai.aes.aescommon.service.binary.job.supplyorg.SharedOrganizationJob;
import com.amkai.aes.aescommon.service.binary.job.testing.TestJob;
import com.amkai.aes.aescommon.service.binary.job.waitingroom.GetCasesSuperBillsJob;
import com.amkai.aes.aescommon.service.binarymanager.BinaryManagerJob;
import com.amkai.aes.aescommon.service.calendar.CalendarJob;
import com.amkai.aes.aescommon.service.compaund.CompaundJob;
import com.amkai.aes.aescommon.service.conflict.ConflictCheckingJob;
import com.amkai.aes.aescommon.service.ddm.DDMJob;
import com.amkai.aes.aescommon.service.diee.DIEEGeneralJob;
import com.amkai.aes.aescommon.service.diee.DIEEJob;
import com.amkai.aes.aescommon.service.diee.DIEEReportPackageJob;
import com.amkai.aes.aescommon.service.diee.DIEEReportTaskJob;
import com.amkai.aes.aescommon.service.diee.DataExportJob;
import com.amkai.aes.aescommon.service.diee.ReportManagerJob;
import com.amkai.aes.aescommon.service.ecm.EcmManagerJob;
import com.amkai.aes.aescommon.service.formengine.FormEngineJob;
import com.amkai.aes.aescommon.service.importer.ImporterJob;
import com.amkai.aes.aescommon.service.importer.ZipCodeProviderJob;
import com.amkai.aes.aescommon.service.messaging.MessagingJob;
import com.amkai.aes.aescommon.service.rcm.RCMJob;
import com.amkai.aes.aescommon.service.references.ReferenceJob;
import com.amkai.aes.aescommon.service.scheduling.SchedulerSettingsJob;
import com.amkai.aes.aescommon.service.scheduling.SchedulingJob;
import com.amkai.aes.aescommon.service.security.PassportSecurityJob;
import com.amkai.aes.aescommon.service.vfs.VfsJob;
import com.amkai.aes.generatedbeans.eventlog.EventLog;
import com.amkai.aes.generatedbeans.organization.Department;
import com.amkai.aes.generatedbeans.passport.Passport;
import com.amkai.aes.server.servlet.jobs.EventLogSaverJob;
import com.amkai.aes.server.servlet.jobs.MemoryLoggerJob;
import com.amkai.aes.server.session.Connection;
import com.amkai.aes.server.session.ServiceSessionManager;
import com.amkai.aes.webservice.binary.objecthandler.ACLoginSupportListHandler;
import com.amkai.aes.webservice.binary.objecthandler.AcLoginSupportSelectorHandler;
import com.amkai.aes.webservice.binary.objecthandler.AgingCalculatorHandler;
import com.amkai.aes.webservice.binary.objecthandler.AmkaiRxRegistrationHandler;
import com.amkai.aes.webservice.binary.objecthandler.BatchCalculatorHandler;
import com.amkai.aes.webservice.binary.objecthandler.BatchInformationHandler;
import com.amkai.aes.webservice.binary.objecthandler.BatchValidatorHandler;
import com.amkai.aes.webservice.binary.objecthandler.CheckExistenceHandler;
import com.amkai.aes.webservice.binary.objecthandler.ClientSettingsHandler;
import com.amkai.aes.webservice.binary.objecthandler.CompaundHandler;
import com.amkai.aes.webservice.binary.objecthandler.DepartmentsListHandler;
import com.amkai.aes.webservice.binary.objecthandler.DesktopContentHandler;
import com.amkai.aes.webservice.binary.objecthandler.DictionaryDataRequestHandler;
import com.amkai.aes.webservice.binary.objecthandler.DictionaryItemSearchHandler;
import com.amkai.aes.webservice.binary.objecthandler.DomainCommitterHandler;
import com.amkai.aes.webservice.binary.objecthandler.ElectronicRemittancePostingHandler;
import com.amkai.aes.webservice.binary.objecthandler.FacilityListHandler;
import com.amkai.aes.webservice.binary.objecthandler.FormsProviderHandler;
import com.amkai.aes.webservice.binary.objecthandler.ForsImportHandler;
import com.amkai.aes.webservice.binary.objecthandler.GeneralHandler;
import com.amkai.aes.webservice.binary.objecthandler.GetAllSuperBillTypeHandler;
import com.amkai.aes.webservice.binary.objecthandler.InsurancePolicyCaseVerificationCommiterHandler;
import com.amkai.aes.webservice.binary.objecthandler.IsPartiallySharedItemRequiredFieldsFilledJobHandler;
import com.amkai.aes.webservice.binary.objecthandler.ItemHandler;
import com.amkai.aes.webservice.binary.objecthandler.KeepSessionHandler;
import com.amkai.aes.webservice.binary.objecthandler.ListHandler;
import com.amkai.aes.webservice.binary.objecthandler.LoginHandler;
import com.amkai.aes.webservice.binary.objecthandler.LoginRelatedOperationsHandler;
import com.amkai.aes.webservice.binary.objecthandler.LogoutHandler;
import com.amkai.aes.webservice.binary.objecthandler.MessagingHandler;
import com.amkai.aes.webservice.binary.objecthandler.NewObjectHandler;
import com.amkai.aes.webservice.binary.objecthandler.NodeTreeHandler;
import com.amkai.aes.webservice.binary.objecthandler.OccupationHandler;
import com.amkai.aes.webservice.binary.objecthandler.PassportListHandler;
import com.amkai.aes.webservice.binary.objecthandler.PassportManagerHandler;
import com.amkai.aes.webservice.binary.objecthandler.PeriodAndBatchJobHandler;
import com.amkai.aes.webservice.binary.objecthandler.PersonInsuranceInfoHandler;
import com.amkai.aes.webservice.binary.objecthandler.PersonRelaionshipsHandler;
import com.amkai.aes.webservice.binary.objecthandler.PersonUniqueQueryHandler;
import com.amkai.aes.webservice.binary.objecthandler.PhysStaffListHandler;
import com.amkai.aes.webservice.binary.objecthandler.ProcedureCarrierCodeHandler;
import com.amkai.aes.webservice.binary.objecthandler.RADBeanSaveHandler;
import com.amkai.aes.webservice.binary.objecthandler.RADBeanUniquePropertyHandler;
import com.amkai.aes.webservice.binary.objecthandler.ReferenceHandler;
import com.amkai.aes.webservice.binary.objecthandler.RegistrationValidationHandler;
import com.amkai.aes.webservice.binary.objecthandler.RemarkJobHandler;
import com.amkai.aes.webservice.binary.objecthandler.RemittancePostingHandler;
import com.amkai.aes.webservice.binary.objecthandler.RequestHandler;
import com.amkai.aes.webservice.binary.objecthandler.SchedulingHandler;
import com.amkai.aes.webservice.binary.objecthandler.SearchCountHandler;
import com.amkai.aes.webservice.binary.objecthandler.SearchTableHandler;
import com.amkai.aes.webservice.binary.objecthandler.SettingPropertyHandler;
import com.amkai.aes.webservice.binary.objecthandler.UpLoadHandler;
import com.amkai.aes.webservice.binary.objecthandler.UpdateHandler;
import com.amkai.aes.webservice.binary.objecthandler.UploadCommitHandler;
import com.amkai.aes.webservice.binary.objecthandler.ValidationHandler;
import com.amkai.aes.webservice.binary.objecthandler.VersionTitleAndSupportedVersionsGetterHandler;
import com.amkai.aes.webservice.binary.objecthandler.audittrail.AuditTrailHandler;
import com.amkai.aes.webservice.binary.objecthandler.billing.AnesthesiaCalculationGetterHandler;
import com.amkai.aes.webservice.binary.objecthandler.billing.AutoPostingHandler;
import com.amkai.aes.webservice.binary.objecthandler.billing.BatchHandler;
import com.amkai.aes.webservice.binary.objecthandler.billing.BillingHandler;
import com.amkai.aes.webservice.binary.objecthandler.billing.ChargeEntryHandler;
import com.amkai.aes.webservice.binary.objecthandler.billing.ChargeImportHandler;
import com.amkai.aes.webservice.binary.objecthandler.billing.ChargeProviderHandler;
import com.amkai.aes.webservice.binary.objecthandler.billing.ClaimCustomizationHandler;
import com.amkai.aes.webservice.binary.objecthandler.billing.DeleteBatchHandler;
import com.amkai.aes.webservice.binary.objecthandler.billing.GroupRebillHandler;
import com.amkai.aes.webservice.binary.objecthandler.billing.ImportCheckoutHandler;
import com.amkai.aes.webservice.binary.objecthandler.billing.InsuranceBillingHandler;
import com.amkai.aes.webservice.binary.objecthandler.billing.InsuranceBillingHistoryHandler;
import com.amkai.aes.webservice.binary.objecthandler.billing.LedgerHandler;
import com.amkai.aes.webservice.binary.objecthandler.billing.LedgerSettingsHandler;
import com.amkai.aes.webservice.binary.objecthandler.billing.PatientStatementHistoryHandler;
import com.amkai.aes.webservice.binary.objecthandler.billing.PeriodHandler;
import com.amkai.aes.webservice.binary.objecthandler.billing.PrintBillHandler;
import com.amkai.aes.webservice.binary.objecthandler.billing.TransferToBillingGroupHandler;
import com.amkai.aes.webservice.binary.objecthandler.billing.ledger.PWTHandler;
import com.amkai.aes.webservice.binary.objecthandler.binarymanager.BinaryManagerHandler;
import com.amkai.aes.webservice.binary.objecthandler.calendar.CalendarHandler;
import com.amkai.aes.webservice.binary.objecthandler.casecosting.CaseCostingHandler;
import com.amkai.aes.webservice.binary.objecthandler.casecosting.CaseCostingParameterHandler;
import com.amkai.aes.webservice.binary.objecthandler.casehistory.ASCAnesthesiaImportHandler;
import com.amkai.aes.webservice.binary.objecthandler.casehistory.CDMImporterHandler;
import com.amkai.aes.webservice.binary.objecthandler.casehistory.CaseHistoryHelperJobHandler;
import com.amkai.aes.webservice.binary.objecthandler.casehistory.CaseHistoryJobHandler;
import com.amkai.aes.webservice.binary.objecthandler.casehistory.CaseHistorySyncJobHandler;
import com.amkai.aes.webservice.binary.objecthandler.casehistory.ChartDocAppAssocHandler;
import com.amkai.aes.webservice.binary.objecthandler.casehistory.ChartDocumentsJobHandler;
import com.amkai.aes.webservice.binary.objecthandler.casehistory.ImportCDMHandler;
import com.amkai.aes.webservice.binary.objecthandler.casehistory.IsBilledHandler;
import com.amkai.aes.webservice.binary.objecthandler.casehistory.PreferenceCardLoaderHandler;
import com.amkai.aes.webservice.binary.objecthandler.casehistory.SerialNumberJobHandler;
import com.amkai.aes.webservice.binary.objecthandler.casehistory.SharedDictionaryJobHandler;
import com.amkai.aes.webservice.binary.objecthandler.conflict.ConflictCheckingHandler;
import com.amkai.aes.webservice.binary.objecthandler.contract.ContractHandler;
import com.amkai.aes.webservice.binary.objecthandler.contract.ContractImportHandler;
import com.amkai.aes.webservice.binary.objecthandler.contract.TransientContractProviderHandler;
import com.amkai.aes.webservice.binary.objecthandler.ddm.DDMHandler;
import com.amkai.aes.webservice.binary.objecthandler.dictionary.DictionaryActivationHandler;
import com.amkai.aes.webservice.binary.objecthandler.dictionary.DictionaryDeactivatingValidatorHandler;
import com.amkai.aes.webservice.binary.objecthandler.dictionary.DictionaryEditorSavingValidationHandler;
import com.amkai.aes.webservice.binary.objecthandler.dictionary.GetItemInCurrentOrGivenBusinessEntityHandler;
import com.amkai.aes.webservice.binary.objecthandler.dictionary.GetStateCodeValuesHandler;
import com.amkai.aes.webservice.binary.objecthandler.dictionary.GetStatesForDepartmentsHandler;
import com.amkai.aes.webservice.binary.objecthandler.dictionary.InsuranceClaimOfficeAndPlanDeleteValidationHandler;
import com.amkai.aes.webservice.binary.objecthandler.dictionary.IsContractSetForPlanPoliciesHandler;
import com.amkai.aes.webservice.binary.objecthandler.dictionary.IsPhysStaffPersonIdExistJobHandler;
import com.amkai.aes.webservice.binary.objecthandler.dictionary.ItemSkeletonGetterHandler;
import com.amkai.aes.webservice.binary.objecthandler.dictionary.ItemStateCodesGetterHandler;
import com.amkai.aes.webservice.binary.objecthandler.dictionary.SupplyResourceItemJobHandler;
import com.amkai.aes.webservice.binary.objecthandler.diee.DIEEGeneralHandler;
import com.amkai.aes.webservice.binary.objecthandler.diee.DIEEHandler;
import com.amkai.aes.webservice.binary.objecthandler.diee.DIEEReportPackageHandler;
import com.amkai.aes.webservice.binary.objecthandler.diee.DIEEReportTaskHandler;
import com.amkai.aes.webservice.binary.objecthandler.diee.DataExportHandler;
import com.amkai.aes.webservice.binary.objecthandler.diee.ReportManagerHandler;
import com.amkai.aes.webservice.binary.objecthandler.ecm.EcmManagerHandler;
import com.amkai.aes.webservice.binary.objecthandler.feeschedule.FeeScheduleHandler;
import com.amkai.aes.webservice.binary.objecthandler.formengine.FormEngineHandler;
import com.amkai.aes.webservice.binary.objecthandler.importer.ImporterHandler;
import com.amkai.aes.webservice.binary.objecthandler.importer.ZipCodeHandler;
import com.amkai.aes.webservice.binary.objecthandler.init.RadBeanInitializationHandler;
import com.amkai.aes.webservice.binary.objecthandler.inventory.AesCriteriaJobHandler;
import com.amkai.aes.webservice.binary.objecthandler.inventory.BEFacilitiesAddressHandler;
import com.amkai.aes.webservice.binary.objecthandler.inventory.DepartmentFacilitiesHandler;
import com.amkai.aes.webservice.binary.objecthandler.inventory.ElectronicPurchaseOrderHandler;
import com.amkai.aes.webservice.binary.objecthandler.inventory.InventoryElementCalculatorHandler;
import com.amkai.aes.webservice.binary.objecthandler.inventory.InventoryJobHandler;
import com.amkai.aes.webservice.binary.objecthandler.inventory.OrderRequisitionsHandler;
import com.amkai.aes.webservice.binary.objecthandler.inventory.PhysicalInventoryJobHandler;
import com.amkai.aes.webservice.binary.objecthandler.inventory.PoNumberHandler;
import com.amkai.aes.webservice.binary.objecthandler.inventory.PurchaseOrderLinesHandler;
import com.amkai.aes.webservice.binary.objecthandler.inventory.PurchaseOrderNumberCheckerHandler;
import com.amkai.aes.webservice.binary.objecthandler.inventory.PurchaseOrdersHandler;
import com.amkai.aes.webservice.binary.objecthandler.inventory.RADBeanQueryHandler;
import com.amkai.aes.webservice.binary.objecthandler.inventory.RequisitionNumberHandler;
import com.amkai.aes.webservice.binary.objecthandler.inventory.SimpleItemHandler;
import com.amkai.aes.webservice.binary.objecthandler.inventory.VendorOrderInformarionPropertiesHandler;
import com.amkai.aes.webservice.binary.objecthandler.inventory.VendorOrderInformationHandler;
import com.amkai.aes.webservice.binary.objecthandler.inventory.VendorOrderManufacterHandler;
import com.amkai.aes.webservice.binary.objecthandler.license.LicenseManagerHandler;
import com.amkai.aes.webservice.binary.objecthandler.locking.LockJobHandler;
import com.amkai.aes.webservice.binary.objecthandler.organization.AreDataRecordedForDepartmentHandler;
import com.amkai.aes.webservice.binary.objecthandler.organization.EnterpriseTreeHandler;
import com.amkai.aes.webservice.binary.objecthandler.personnel.PersonnelJobHandler;
import com.amkai.aes.webservice.binary.objecthandler.personnel.PrivilegeProcedureHandler;
import com.amkai.aes.webservice.binary.objecthandler.prefcards.PhysStaffLoaderHandler;
import com.amkai.aes.webservice.binary.objecthandler.prefcards.PrefCardPrintingPatientQueryHandler;
import com.amkai.aes.webservice.binary.objecthandler.prefcards.PreferenceCardHandler;
import com.amkai.aes.webservice.binary.objecthandler.prefcards.PreferenceCardQueryHandler;
import com.amkai.aes.webservice.binary.objecthandler.preference.PreferenceJobHandler;
import com.amkai.aes.webservice.binary.objecthandler.rcm.RCMHandler;
import com.amkai.aes.webservice.binary.objecthandler.registration.AppoitmentsToRegistrationHandler;
import com.amkai.aes.webservice.binary.objecthandler.registration.BgSpecificPropertiesJobHandler;
import com.amkai.aes.webservice.binary.objecthandler.registration.EstimatedRevenueHandler;
import com.amkai.aes.webservice.binary.objecthandler.registration.ExternalIdJobHandler;
import com.amkai.aes.webservice.binary.objecthandler.registration.FreeAppointmentHandler;
import com.amkai.aes.webservice.binary.objecthandler.registration.GetCasesSuperBillsHandler;
import com.amkai.aes.webservice.binary.objecthandler.registration.GetEnterpriseCasesHandler;
import com.amkai.aes.webservice.binary.objecthandler.registration.InsurancePlanHandler;
import com.amkai.aes.webservice.binary.objecthandler.registration.InsurancePolicyCaseVerifiationJobHandler;
import com.amkai.aes.webservice.binary.objecthandler.registration.LoadSpecifiedRegistrationDataHandler;
import com.amkai.aes.webservice.binary.objecthandler.registration.PatientBalanceCheckingHandler;
import com.amkai.aes.webservice.binary.objecthandler.registration.PatientLabelJobHandler;
import com.amkai.aes.webservice.binary.objecthandler.registration.PmCaseJobHandler;
import com.amkai.aes.webservice.binary.objecthandler.registration.RegistrationHandler;
import com.amkai.aes.webservice.binary.objecthandler.registration.RelationshipHandler;
import com.amkai.aes.webservice.binary.objecthandler.scheduler.AvailableResourcesConflictCheckingHanlder;
import com.amkai.aes.webservice.binary.objecthandler.scheduler.CaseCommitHandler;
import com.amkai.aes.webservice.binary.objecthandler.scheduler.IsPreferenceCardLoadedForAppointmentInCDMHandler;
import com.amkai.aes.webservice.binary.objecthandler.scheduler.SchedulerSettingsJobHandler;
import com.amkai.aes.webservice.binary.objecthandler.security.PassportSecurityHandler;
import com.amkai.aes.webservice.binary.objecthandler.security.SecurityManagerHandler;
import com.amkai.aes.webservice.binary.objecthandler.supplyorg.SharedOrganizationHandler;
import com.amkai.aes.webservice.binary.objecthandler.testing.TestJobHandler;
import com.amkai.aes.webservice.binary.objecthandler.vfs.VfsHandler;
import com.amkai.common.base.versioning.AoConcurrentModificationException;
import com.amkai.common.extensions.hibernate.config.manager.SessionManager;
import com.amkai.rad.designerbase.beans.ChangedKind;
import com.amkai.rad.designerbase.beans.instancecounter.RADBeanInstanceCounter;

/**
 * JobManager
 * @author Miskolczi P�ter
 * Description:
 *
 */
public class JobManager implements JobManagerInterface {
	
	private static final Log log = LogFactory.getLog(JobManager.class);
	
	private static final int SLOW = 1500;
	private static final int VERY_SLOW = 5000;


	private static JobManager instance = new JobManager();
	
	private Map<Class<? extends Job>, JobObjectHandler> objectHandlers = new HashMap<Class<? extends Job>, JobObjectHandler>();
	
	private Set<Job> currentJobs = Collections.synchronizedSet(new HashSet<Job>());
	
	// public constructor is needed for the AesClient WebService emulation
	public JobManager() {
		registerObjectHandlers();
		System.out.println("::Set the JobManagerInterface to MemoryLoggerJob.");
		MemoryLoggerJob.setJobManagerInterface(this);
	}
	
	public static Serializable processJobObject(Job job, Serializable inputObject) throws Exception {
		return instance.processObject(job, inputObject);
	}
	
	private String jobInfo(Job job) {
		String sInfo = "No session";
		Connection c = ServiceSessionManager.getConnection();
		if (c != null) {
			Passport p = c.getRuntimePassport();
			if (p != null) {
				sInfo = p.getId().toString();
			} else {
				sInfo = "No passport";
			}
			sInfo += "  " + c.getClientHost();
		}
		return job.toString() + "  " + sInfo;
	} 
	
	private final EventLog createEventLog(String jobInfo, String jobExtra, Department department) {
		EventLog eventLog = new EventLog();
		eventLog.setChangedKind(ChangedKind.CREATED);
		eventLog.setStarted(new Date());
		eventLog.setJobInfo(jobInfo);
		eventLog.setJobExtra(jobExtra);
		eventLog.setThread(Thread.currentThread().getName());
		eventLog.setBusinessEntity(department);
		Connection c = ServiceSessionManager.getConnection();
		if (c != null) {
			eventLog.setSession(c.getSession().getId());
			eventLog.setPassport(c.getRuntimePassport());
			eventLog.setClientHost(c.getClientHost());
		}
		return eventLog;
	}
	
	@Override
	public Serializable processObject(Job job, Serializable inputObject) throws Exception {
		EventLogSaverJob.incrementJobCounter();
		boolean logEvents = EventLogSaverJob.JOB_INFO_TO_EVENTLOG_TABLE && AESSettings.getServerSettings().getAmkaiOfficeConfig().getRuntime().isEventLog();
		EventLog eventLog = null;
		EventLog errorLog = null;
		if (logEvents) {
			//eventLog = RADBeanFactory.getInstance().createBean(EventLog.class);
			eventLog = createEventLog(job.getDisplayInfo(), job.getExtraInfo(), job.getModuleDepartment());
			eventLog.setJob(job.getClass().getSimpleName());
			job.setEventLog(eventLog);
		}

		try {
			Job.currentJob.set(job);
			RADBeanInstanceCounter.instance.setJobInfo(job.getJobInfoForMemoryLogger());
			currentJobs.add(job);
			try {
				job.startedAt = System.currentTimeMillis();
				SessionManager.dropSessionAndTransaction("before job: " + jobInfo(job));
				try {
					JobObjectHandler objectHandler = objectHandlers.get(job.getClass());
					if (objectHandler != null) {
						return processObject(job, inputObject, objectHandler);
					}
					else {
						throw new HandlerNotFoundException("No handler found for "+job.getClass().getName());
					}
				} finally {
					SessionManager.dropSessionAndTransaction("after job: " + jobInfo(job));
				}
			} finally {
				currentJobs.remove(job);
				RADBeanInstanceCounter.instance.setJobInfo(null);
				Job.currentJob.set(null);
			}
		} catch (AoConcurrentModificationException ex) {
			if (logEvents) {
				errorLog = createEventLog(ex.getMessage(), ex.getDescription(), job.getModuleDepartment());
			}
			throw ex;
		} finally {
			if (logEvents) {
				if (eventLog!=null) {
					eventLog.setStopped(new Date());
					eventLog.setElapsed((int) (eventLog.getStopped().getTime() - eventLog.getStarted().getTime()));
					EventLogSaverJob.addEventLog(eventLog);
				}
				if (errorLog!=null) {
					errorLog.setParent(eventLog);
					EventLogSaverJob.addEventLog(errorLog);
				}
			}
		}
	}
	
	private Serializable internalProcessObject(Job job, Serializable inputObject, JobObjectHandler objectHandler) throws Exception {
		Date startDate = new Date();
		Serializable result = objectHandler.process(job, inputObject);
		Date stopDate = new Date();
		long ellapsed = stopDate.getTime() - startDate.getTime();
		String extraEllapsed = "";
		if (ellapsed > SLOW) {
			if (ellapsed > VERY_SLOW) {
				extraEllapsed = "LIMIT2"; // VERY_SLOW
			} else {
				extraEllapsed = "LIMIT1"; // SLOW
			}
		}
		String info = "Job time: " + jobInfo(job) + "  "+ extraEllapsed + "   " + new Long(ellapsed).toString() + " msec";
		log.info(info);
		return result;
	}
	
	// AES-3298
	public Serializable processObject(Job job, Serializable inputObject, JobObjectHandler objectHandler) throws Exception {
		return internalProcessObject(job, inputObject, objectHandler);
	}
	
	private void registerObject(Class<? extends Job> clazz, JobObjectHandler objectHandler) {
		objectHandlers.put(clazz, objectHandler);
	}
	
	/**
	 * Here must to register the Job Upload sourceHandlers.
	 * Method: registerUploadHandlers
	 */
	private void registerObjectHandlers() {
//		registerObject(PatientTransferJob.class, new PatientHandler());
//		registerObject(PersonTransferJob.class, new PersonHandler());
		registerObject(OccupationTransferJob.class, new OccupationHandler());
		registerObject(TreeNodeJob.class, new NodeTreeHandler());
		registerObject(CreateNewObjectJob.class, new NewObjectHandler());
		registerObject(UpdateJob.class, new UpdateHandler());
		registerObject(RequestJob.class, new RequestHandler());
		registerObject(LoginJob.class, new LoginHandler());
		registerObject(ItemJob.class, new ItemHandler());
		registerObject(SearchJob.class, new SearchTableHandler());
		//AES-8333
		registerObject(SearchCountJob.class, new SearchCountHandler());
		registerObject(ListJob.class, new ListHandler());
		registerObject(PassportListJob.class, new PassportListHandler());
		registerObject(UpLoadJob.class, new UpLoadHandler());
		registerObject(BinaryUploadCommitJob.class, new UploadCommitHandler());
		registerObject(DomainCommitterJob.class, new DomainCommitterHandler());
		registerObject(PassportManagerJob.class, new PassportManagerHandler());
//		registerObject(RoleManagerJob.class, new RoleManagerHandler());
		registerObject(GetAllSuperBillTypeJob.class, new GetAllSuperBillTypeHandler());
		registerObject(InitializationJob.class, new RadBeanInitializationHandler());
		registerObject(DepartmentsListJob.class, new DepartmentsListHandler());
		registerObject(LogoutJob.class, new LogoutHandler());
		registerObject(PersonUniqueJob.class, new PersonUniqueQueryHandler());
		registerObject(PersonRelationshipJob.class, new RelationshipHandler());
		registerObject(PersonRelationshipsJob.class, new PersonRelaionshipsHandler());
		registerObject(RADBeanSaveJob.class, new RADBeanSaveHandler());
		registerObject(GetCasesSuperBillsJob.class, new GetCasesSuperBillsHandler());
		registerObject(GeneralJob.class, new GeneralHandler());
		registerObject(ValidationJob.class, new ValidationHandler());
		registerObject(RegistrationValidationJob.class, new RegistrationValidationHandler());
		registerObject(DesktopContentJob.class, new DesktopContentHandler());
		registerObject(ACLoginSupportGetterJob.class, new ACLoginSupportListHandler());
		registerObject(ACLoginSupportSelectorJob.class, new AcLoginSupportSelectorHandler());
		registerObject(DictionaryDataRequestJob.class, new DictionaryDataRequestHandler());
		registerObject(PersonInsuranceInfoJob.class, new PersonInsuranceInfoHandler());
		registerObject(SchedulingJob.class, new SchedulingHandler());
		registerObject(ReferenceJob.class, new ReferenceHandler());
		registerObject(CompaundJob.class, new CompaundHandler());
		registerObject(DeleteBatchJob.class, new DeleteBatchHandler());
		registerObject(ImportCheckoutJob.class, new ImportCheckoutHandler());
		registerObject(FormsProviderJob.class, new FormsProviderHandler());
		registerObject(DictionaryActivationJob.class, new DictionaryActivationHandler());
		registerObject(PrintBillJob.class, new PrintBillHandler());
		registerObject(ClaimCustomizationJob.class, new ClaimCustomizationHandler());
		registerObject(TestJob.class, new TestJobHandler());
		registerObject(MessagingJob.class, new MessagingHandler());
		registerObject(DataExportJob.class, new DataExportHandler());
		registerObject(DDMJob.class, new DDMHandler());
		registerObject(RCMJob.class, new RCMHandler());
		registerObject(CalendarJob.class, new CalendarHandler());
		registerObject(EcmManagerJob.class, new EcmManagerHandler());
		registerObject(ImporterJob.class, new ImporterHandler());
		registerObject(ZipCodeProviderJob.class, new ZipCodeHandler());
		registerObject(ReportManagerJob.class, new ReportManagerHandler());
		registerObject(PhysStaffJob.class, new PhysStaffListHandler()); // CyB
		registerObject(PrivilegeProcedureJob.class, new PrivilegeProcedureHandler()); //CyB
		registerObject(DictionaryItemSearchJob.class, new DictionaryItemSearchHandler());
		registerObject(PreferenceCardQueryJob.class, new PreferenceCardQueryHandler());
		registerObject(SimpleItemJob.class, new SimpleItemHandler());
		registerObject(AesCriteriaJob.class, new AesCriteriaJobHandler());
		registerObject(BatchCalculatorJob.class, new BatchCalculatorHandler());
		registerObject(AgingCalculatorJob.class, new AgingCalculatorHandler());		
		registerObject(ForsImportJob.class, new ForsImportHandler());
		registerObject(InsurancePolicyCaseVerifiationJob.class, new InsurancePolicyCaseVerifiationJobHandler());
		registerObject(GetEnterpriseCasesJob.class, new GetEnterpriseCasesHandler());
		registerObject(ProcedureCarrierCodeJob.class, new ProcedureCarrierCodeHandler()); //CyB		
		registerObject(ChartDocAppAssocJob.class, new ChartDocAppAssocHandler());
		registerObject(CaseHistoryJob.class, new CaseHistoryJobHandler());
		registerObject(CaseHistoryHelperJob.class, new CaseHistoryHelperJobHandler());
		registerObject(ChartDocumentsJob.class, new ChartDocumentsJobHandler());
		registerObject(IsPhysStaffPersonIdExistJob.class, new IsPhysStaffPersonIdExistJobHandler());
		registerObject(CheckExistenceJob.class, new CheckExistenceHandler());
		registerObject(PatientLabelJob.class, new PatientLabelJobHandler());
		registerObject(IsPartiallySharedItemRequiredFieldsFilledJob.class, new IsPartiallySharedItemRequiredFieldsFilledJobHandler());
		registerObject(CaseCommitJob.class, new CaseCommitHandler());		
		registerObject(ChargeProviderJob.class, new ChargeProviderHandler());
		registerObject(SharedOrganizationJob.class, new SharedOrganizationHandler());
		registerObject(AppointmentsToRegistrationJob.class, new AppoitmentsToRegistrationHandler());
		registerObject(RemarkJob.class, new RemarkJobHandler());
		registerObject(BatchValidatorJob.class, new BatchValidatorHandler());
		registerObject(PeriodAndBatchJob.class, new PeriodAndBatchJobHandler());
		registerObject(PatientBalanceCheckingJob.class, new PatientBalanceCheckingHandler());
		registerObject(AreDataRecordedForDepartmentJob.class, new AreDataRecordedForDepartmentHandler());
		registerObject(VersionTitleAndSupportedVersionsGetterJob.class, new VersionTitleAndSupportedVersionsGetterHandler());
		registerObject(PreferenceCardLoaderJob.class, new PreferenceCardLoaderHandler());
		registerObject(DIEEJob.class, new DIEEHandler());
		registerObject(DIEEGeneralJob.class, new DIEEGeneralHandler());
		registerObject(DIEEReportTaskJob.class, new DIEEReportTaskHandler());
		registerObject(DIEEReportPackageJob.class, new DIEEReportPackageHandler());
		registerObject(FacilityListJob.class,new FacilityListHandler());
		registerObject(FreeAppointmentsJob.class, new FreeAppointmentHandler());
		registerObject(ConflictCheckingJob.class, new ConflictCheckingHandler());
		registerObject(InventoryElementCalculatorJob.class, new InventoryElementCalculatorHandler());
		registerObject(PrefCardPrinterPatientQueryJob.class, new PrefCardPrintingPatientQueryHandler());
		registerObject(RADBeanUniquePropertyJob.class, new RADBeanUniquePropertyHandler());
		registerObject(InsurancePolicyCaseVerificationCommiterJob.class, new InsurancePolicyCaseVerificationCommiterHandler());
		registerObject(ContractJob.class,new ContractHandler());
		registerObject(BillingJob.class,new BillingHandler());
		registerObject(RADBeanQueryJob.class, new RADBeanQueryHandler());
		// aes-form-engine
		registerObject(FormEngineJob.class, new FormEngineHandler());
		// contracts
		registerObject(ImportCDMJob.class, new ImportCDMHandler()); //veghar AES-5502
		registerObject(PassportSecurityJob.class, new PassportSecurityHandler());		
		registerObject(SecurityManagerJob.class, new SecurityManagerHandler());
		registerObject(ItemStateCodesGetterJob.class, new ItemStateCodesGetterHandler());
		registerObject(GetStatesForDepartmentsJob.class, new GetStatesForDepartmentsHandler());
		//casecosting
		registerObject(CaseCostingParameterJob.class, new CaseCostingParameterHandler());
		registerObject(CaseCostingJob.class, new CaseCostingHandler());
		registerObject(GetStateCodeValuesJob.class, new GetStateCodeValuesHandler());
		
		registerObject(PatientStatementHistoryJob.class, new PatientStatementHistoryHandler());
		registerObject(BatchInformationJob.class, new BatchInformationHandler());
		registerObject(InsuranceBillingHistoryJob.class, new InsuranceBillingHistoryHandler());
		registerObject(PhysStaffLoaderJob.class, new PhysStaffLoaderHandler());
		registerObject(ChargeImportJob.class, new ChargeImportHandler());
//		registerObject(LedgerProviderJob.class, new LedgerProviderHandler());
		registerObject(SettingPropertyJob.class, new SettingPropertyHandler());
		registerObject(FeeScheduleJob.class, new FeeScheduleHandler());
		registerObject(IsBilledJob.class, new IsBilledHandler() );
		registerObject(IsPreferenceCardLoadedForAppointmentInCDMJob.class, new IsPreferenceCardLoadedForAppointmentInCDMHandler());
		registerObject(ItemSkeletonGetterJob.class, new ItemSkeletonGetterHandler());
		registerObject(GroupRebillJob.class, new GroupRebillHandler());
		registerObject(RemittancePostingJob.class, new RemittancePostingHandler());
		// AES-17150
		registerObject(ElectronicRemittancePostingJob.class, new ElectronicRemittancePostingHandler());
		registerObject(PeriodJob.class, new PeriodHandler());
		registerObject(BatchJob.class, new BatchHandler());
		registerObject(LedgerSettingsJob.class, new LedgerSettingsHandler());
		registerObject(ChargeEntryJob.class, new ChargeEntryHandler());
		registerObject(LedgerJob.class, new LedgerHandler());
		registerObject(AutoPostingJob.class, new AutoPostingHandler());
		registerObject(PWTJob.class, new PWTHandler());
		registerObject(InsuranceBillingJob.class, new InsuranceBillingHandler());
		
		// Inventory Jobs
		registerObject(InventoryJob.class, new InventoryJobHandler());
		
		registerObject(VendorOrderManufacterJob.class, new VendorOrderManufacterHandler());
		registerObject(PurchaseOrderNumberCheckerJob.class, new PurchaseOrderNumberCheckerHandler());
		registerObject(OrderRequisitionNumberJob.class, new RequisitionNumberHandler());
		registerObject(OrderRequisitionsJob.class, new OrderRequisitionsHandler());
		// AES-17426
		registerObject(ElectronicPurchaseOrderJob.class, new ElectronicPurchaseOrderHandler());		
		
		registerObject(SharedDictionaryJob.class, new SharedDictionaryJobHandler());
		registerObject(VendorOrderInformationPropertiesJob.class, new VendorOrderInformarionPropertiesHandler());
		registerObject(VendorOrderInformationJob.class, new VendorOrderInformationHandler());
		//registerObject(PurchaseOrderJob.class, new PurchaseOrderHandler());
		registerObject(PurchaseOrdersJob.class, new PurchaseOrdersHandler());
		registerObject(PurchaseOrderLinesJob.class, new PurchaseOrderLinesHandler() );
		registerObject(PoNumberJob.class, new PoNumberHandler());
		registerObject(GetItemInCurrentOrGivenBusinessEntityJob.class, new GetItemInCurrentOrGivenBusinessEntityHandler());
        registerObject(InsuranceClaimOfficeAndPlanDeleteValidationJob.class, new InsuranceClaimOfficeAndPlanDeleteValidationHandler());

        registerObject(CDMImporterJob.class, new CDMImporterHandler());
		
		//Audit trail job(s)
		registerObject(AuditTrailJob.class, new AuditTrailHandler());
		//VFS
		registerObject(VfsJob.class, new VfsHandler());

		registerObject(CaseHistorySyncJob.class, new CaseHistorySyncJobHandler());
		
		registerObject(SerialNumberJob.class, new SerialNumberJobHandler());
		
		registerObject(SupplyResourceItemJob.class, new SupplyResourceItemJobHandler());
	
		//Scheduler related jobs 
		//#7961
		registerObject(SchedulerSettingsJob.class, new SchedulerSettingsJobHandler());
		
		registerObject(BEFacilitiesAddressJob.class, new BEFacilitiesAddressHandler());
		registerObject(DepratmentFacilitiesJob.class, new DepartmentFacilitiesHandler());
		registerObject(KeepSessionJob.class, new KeepSessionHandler());
		//#6565
		registerObject(EstimatedRevenueJob.class, new EstimatedRevenueHandler());
		// KKORNEL: AES-6494
		registerObject(DictionaryDeactivatingValidatorJob.class, new DictionaryDeactivatingValidatorHandler());
		registerObject(LoadSpecifiedRegistrationDataJob.class, new LoadSpecifiedRegistrationDataHandler());
		// KKORNEL: AES-10095
		registerObject(AnesthesiaCalculationGetterJob.class, new AnesthesiaCalculationGetterHandler());
		registerObject(PhysicalInventoryJob.class, new PhysicalInventoryJobHandler());
		// KKORNEL: AES-6497
		registerObject(ASCAnesthesiaImportJob.class, new ASCAnesthesiaImportHandler());
		// KKORNEL: AES-7580
		registerObject(TransientContractProviderJob.class, new TransientContractProviderHandler());
		registerObject(PreferenceCardJob.class, new PreferenceCardHandler());
		// KKORNEL: AES-9162
		registerObject(DictionaryEditorSavingValidationJob.class, new DictionaryEditorSavingValidationHandler());
		//#12512
		registerObject(LoginRelatedOperationsJob.class, new LoginRelatedOperationsHandler());
		//AES-12567
		registerObject(BgSpecificPropertiesJob.class, new BgSpecificPropertiesJobHandler());
		registerObject(TransferToBgJob.class, new TransferToBillingGroupHandler());
		registerObject(InsurancePlanJob.class, new InsurancePlanHandler());
		//DP : http://jira.amkai.com:8080/browse/AES-12218
		registerObject(ContractImportJob.class, new ContractImportHandler());
		// KKORNEL: AES-10934
		registerObject(IsContractSetForPlanPoliciesJob.class, new IsContractSetForPlanPoliciesHandler());
		registerObject(PmCaseJob.class , new PmCaseJobHandler());
		// AES-14483
		registerObject(ExternalIdJob.class , new ExternalIdJobHandler());
		// KKORNEL: AES-13957
		registerObject(AvailableResourcesConflictCheckingJob.class, new AvailableResourcesConflictCheckingHanlder());
		// KKORNEL: AES-14959
		registerObject(RegistrationJob.class, new RegistrationHandler());
		// KKORNEL: AES-14980
		registerObject(PersonnelJob.class, new PersonnelJobHandler());
		
		// AES-16033
		registerObject(LockJob.class, new LockJobHandler());

		// KKORNEL: AES-17127
		registerObject(ClientSettingsJob.class, new ClientSettingsHandler());
		
		//GYAND AES-17197 
		registerObject(AmkaiRxRegistrationJob.class, new AmkaiRxRegistrationHandler());
		//GYAND AES-17197 
		
		// KKORNEL: AES-18018
		registerObject(PreferenceJob.class, new PreferenceJobHandler());
		
		// AES-18099
		registerObject(EnterpriseTreeJob.class, new EnterpriseTreeHandler());
		
		//#18021
		registerObject(LicenseJob.class, new LicenseManagerHandler());
		
		// AES-18450
		registerObject(BinaryManagerJob.class, new BinaryManagerHandler());
	}

	@Override
	public Job[] getCurrentJobs() {
		Job[] result = currentJobs.toArray(new Job[0]);
		return result;
	}
	
}

